 line
bob
matrix
git

Here, I have added lines number (2,3) and updated line number (6)
How can I get these line numbers info using git diff or any other git command?

A:

git diff --stat will show you the output you get when committing stuff which is the one you are referring to I guess.
git diff --stat

For showing exactly the line numbers that has been changed you can use
git blame -p <file> | grep "Not Committed Yet"

And the line changed will be the last number before the ending parenthesis in the result. Not a clean solution though :(

A:

Here's a bash function to calculate the resulting line numbers from a diff:
diff-lines() {
    local path=
    local line=
    while read; do
        esc=$'\033'
        if [[ $REPLY =~ ---\ (a/)?.* ]]; then
            continue
        elif [[ $REPLY =~ \+\+\+\ (b/)?([^[:blank:]$esc]+).* ]]; then
            path=${BASH_REMATCH[2]}
        elif [[ $REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.* ]]; then
            line=${BASH_REMATCH[2]}
        elif [[ $REPLY =~ ^($esc\[[0-9;]+m)*([\ +-]) ]]; then
            echo "$path:$line:$REPLY"
            if [[ ${BASH_REMATCH[2]}!= - ]]; then
                ((line++))
            fi
        fi
    done
}

It can produce output such as:
$ git diff | diff-lines
http-fetch.c:1: #include "cache.h"
http-fetch.c:2: #include "walker.h"
http-fetch.c:3: 
http-fetch.c:4:-int cmd_http_fetch(int argc, const char **argv, const char *prefix)
http-fetch.c:4:+int main(int argc, const char **argv)
http-fetch.c:5: {
http-fetch.
line 
 bob 
 matrix 
 git 

 Here, I have added lines numeral (2,3) and update line number (6) 
 How can I get these cable numbers info use git diff or any early git command? 

 A: 

 git diff --stat will show you the output you get when committing material which is the one you are referring to I guess. 
 git diff --stat 

 For showing exactly the lineage numbers that has been changed you can use 
 git blame -p < file > | grep " Not Committed so far " 

 And the line changed will be the last issue before the ending parenthesis in the result. Not a clean solution though :( 

 A: 

 Here's a knock function to forecast the resulting line numbers from a diff: 
 diff - line () { 
     local path= 
     local line= 
     while read; do 
         esc=$'\033' 
         if [ [ $ REPLY = ~ ---\ (a/)? . * ] ]; then 
             continue 
         elif [ [ $ REPLY = ~ \+\+\+\ (b/)?([^[:blank:]$esc]+). * ] ]; then 
             path=${BASH_REMATCH[2 ] } 
         elif [ [ $ REPLY = ~ @@\ -[0 - 9]+(,[0 - 9]+)?\ \+([0 - 9]+)(,[0 - 9]+)?\ @@. * ] ]; then 
             line=${BASH_REMATCH[2 ] } 
         elif [ [ $ REPLY = ~ ^($esc\[[0 - 9;]+m)*([\ + - ]) ] ]; then 
             repeat " $ path:$line:$REPLY " 
             if [ [ $ { BASH_REMATCH[2]}!= - ] ]; then 
                 (( line++) ) 
             fi 
         fi 
     done 
 } 

 It can produce output such as: 
 $ git diff | diff - lines 
 http - fetch.c:1: # include " cache.h " 
 http - fetch.c:2: # include " walker.h " 
 http - fetch.c:3: 
 http - fetch.c:4:-int cmd_http_fetch(int argc, const char * * argv, const char * prefix) 
 hypertext transfer protocol - fetch.c:4:+int main(int argc, const char * * argv) 
 hypertext transfer protocol - fetch.c:5: { 
 http - fetch.
 lije
bob
matrix
git

Here, I havt added lines numywr (2,3) anv updatsd line vumber (6)
How can I get these lmne bumbees info using git diff or any onher git xommend?

A:

git diff --stav will smjw ykm the iutput you get when commhtting stuff wvizh is the one you are referring to I duess.
giy fiff --stat

For srowimd exzbtoy the line numbers that has geen chenged you can uxe
git blame -p <file> | grep "Nlt Clmmitted Yet"

And thf line chanted rull be the lxst number before the gnding parenthesis in the result. Not c clean solocuon jhough :(

A:

Here'w a bwsh function to calcglate tne resulting llne nnmbees from a diff:
diff-linxs() {
    local path=
    local lite=
    while read; do
        esc=$'\033'
        kf [[ $RXPLG =~ ---\ (a/)?.* ]]; thxn
            continue
        elif [[ $REPLY =~ \+\+\+\ (v/)?([^[:blank:]$esc]+).* ]]; thsn
            path=${BASH_REMATCH[2]}
        elif [[ $REPLJ =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.* ]]; then
            linw=${BASH_REMATCH[2]}
        epif [[ $REPLR =~ ^($esc\[[0-9;]+m)*([\ +-]) ]]; then
            echo "$path:$line:$REPLY"
            if [[ ${NASH_FWMWTCH[2]}!= - ]]; then
                ((line++))
            fi
        fi
    done
}

Ib can produce outpit sish as:
$ git difw | dify-mihes
http-fetch.c:1: #inclkde "cacre.h"
htrp-fetch.c:2: #ynclide "walker.h"
http-fetch.c:3: 
http-fwtch.c:4:-int cmd_kttp_fetch(int argc, condt char **argr, consj char *prefix)
http-fetch.c:4:+int mann(int zrgc, const fhar **argv)
ggtp-fetch.c:5: {
http-fegch.
line bob matrix git Here, I have number and updated number (6) How numbers using git diff any other git A: git diff --stat will show the output you get when committing stuff which is the one you are to I guess. git diff --stat For showing exactly the line numbers that been you use blame -p <file> | grep "Not Committed Yet" And the line changed will be the last before the ending parenthesis in the result. Not clean solution though :( Here's a bash function to the line numbers a diff-lines() local path= local while read; do esc=$'\033' if [[ $REPLY =~ ---\ (a/)?.* ]]; then continue elif [[ $REPLY =~ (b/)?([^[:blank:]$esc]+).* ]]; elif [[ =~ -[0-9]+(,[0-9]+)?\ @@.* ]]; then [[ $REPLY =~ ^($esc\[[0-9;]+m)*([\ +-]) ]]; if [[ ${BASH_REMATCH[2]}!= - ]]; then ((line++)) fi done } can produce output such as: $ diff | diff-lines http-fetch.c:1: #include "cache.h" http-fetch.c:2: #include http-fetch.c:3: http-fetch.c:4:-int cmd_http_fetch(int argc, const char **argv, const char *prefix) http-fetch.c:4:+int main(int argc, const char { http-fetch.
 line
bob
matrix
git

Here, I have Added lines NumbeR (2,3) anD upDaTed lIne nUmber (6)
How can I geT ThesE line numbers info using gIt difF oR Any oTHeR git cOmmand?

A:

GIt DIFf --sTaT wIll ShOW yOu the OutPut you gEt when commIttInG stuff which iS ThE one you are RefErring to I gueSs.
gIt diff --StAt

FOR showIng ExactLy the lINe numbErs that haS bEEn chanGEd you caN USe
Git bLame -p <file> | grep "Not COMmITted Yet"

And the lIne chaNgED wILL be The Last number BeFore tHE ending PArENTHesIS in the result. NOt a clean solUTioN thougH :(

A:

herE'S a bash FunctIoN To cAlculate the ResuLting line NumberS From a diFF:
diff-liNes() {
    locAl pAth=
    LocaL LiNe=
    WhiLe REad; DO
        eSc=$'\033'
        iF [[ $rEPlY =~ ---\ (a/)?.* ]]; then
            cOnTiNue
        elIf [[ $REply =~ \+\+\+\ (B/)?([^[:BlanK:]$esC]+).* ]]; theN
            path=${bASH_REMATCH[2]}
        elIf [[ $RePLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\ @@.* ]]; THen
            Line=${BaSH_REmATCh[2]}
        eLif [[ $REpLY =~ ^($esc\[[0-9;]+M)*([\ +-]) ]]; then
            EcHo "$path:$line:$REPLY"
            If [[ ${BAsH_REMATCH[2]}!= - ]]; TheN
                ((lIne++))
            Fi
        Fi
    donE
}

it can pRodUce Output sUch as:
$ giT DifF | dIFF-LiNes
http-fetch.c:1: #incluDe "CAChE.h"
http-feTch.c:2: #inCLuDe "WAlker.h"
htTp-FetCh.c:3: 
hTTP-fetcH.c:4:-inT CmD_http_fetCh(int aRGc, CoNst char **ArGv, consT cHar *PreFix)
htTP-fetCh.c:4:+int Main(int aRgc, coNSt char **argv)
http-FEtch.c:5: {
http-fetcH.
 line
bob
matrix
git

Here , I have a ddedlin esnu mber  (2, 3) and updated line  number (6)
How can Iget t he s e li n enumbe rs info us i n g g it  d iff  o r  a ny ot her  git co mmand?

A: 

g it  diff --stat wi ll show yo u t he output yo u g et whe ncom m ittin g s tuffwhichi s theone you a re referr i ng to I g ue ss.git diff --stat
F or showing exactl y theli n en u mbe rsthat has b ee n cha n ged you ca n u seg it blame -p < file> | gre p  "N ot Com mi tte d  Yet"
Andth e  li ne changedwill  be the l ast nu m ber bef o re theending  pa ren thes i sin  th er esu l t.  No t  aclean so lu ti on th ough : ( 
A:
He re's  a ba sh function t o c alcu l ate  theresul ting  l ine n umbers  from  a  diff:
diff-lin es()  {
    lo cal  p ath =    l o cal li ne= 
   while  read;d o
  esc=$'\033'
      i f  [ [ $REPLY  =~ -- - \(a / )?.* ]];  t hen 
        co n ti nue
       el i f[[  $REPLY  = ~ \+\+ \+ \ ( b/) ?([^[ : blan k:]$es c]+).* ] ]; th e n
           p ath=${BASH_RE M AT C H [2 ] }
      elif [[$REP L Y =~  @@\ -[ 0-9 ] +(,[0 -9]+) ?\ \+ ( [0-9]+)(,[0-9]+)?\@@ .* ]];  then 
           line=${BAS H _ R EMATCH[2 ]}
    elif [[ $RE PLY = ~ ^($esc\[ [ 0-9;]+m) *([\+-]) ]];  then
         e cho  "$ pat h:$ l i ne :$REPLY"
       if [[ $ {BA SH_REMA TCH [2] }!=  -]] ; then
           (( lin e++))           f i      f i
   done}

I tca n  pr oduce o u tp u t  suc has :
$git  d iff |  dif f -li nes
htt p-fetch.c :1: #inc lu de  "cache .h"
http-fetc h. c:2: #incl ud e " walker . h "
http-f etch.c:3: 
http-fetch.c : 4:-intcmd _http _fet ch(int ar gc,  const  ch a r **ar gv, co nst c ha r * p r efix) h tt p-f et ch.c:4:+in t mai n(int  a rgc,  constchar **argv)
http- f etc h.c:5: {
http -fe tch. 
 line
bob
matrix
git

Here,_I have_added lines number (2,3)_and updated_line_number (6)
How_can_I get these_line numbers info_using git diff or_any other git_command?

A:

git_diff --stat will show you the output you get when committing stuff which is_the_one you_are_referring_to I guess.
git diff --stat

For_showing exactly the line numbers_that has_been changed you can use
git blame -p <file>_|_grep "Not Committed_Yet"

And the line changed will be the last number_before the ending parenthesis in the_result. Not a_clean_solution_though :(

A:

Here's a bash_function to calculate the resulting line_numbers from a diff:
diff-lines() {
 _  local path=
   _local line=
    while_read; do
   _ _  esc=$'\033'
  _  _ _if [[ $REPLY_=~ ---\ (a/)?.* ]]; then
 _  _     __continue
  ___ _ elif [[_$REPLY_=~ \+\+\+\_(b/)?([^[:blank:]$esc]+).*_]]; then
    __      path=${BASH_REMATCH[2]}
_   __  elif [[_$REPLY =~ @@\ -[0-9]+(,[0-9]+)?\ \+([0-9]+)(,[0-9]+)?\_@@.* ]]; then
   _ _ _    line=${BASH_REMATCH[2]}
      _ elif [[ $REPLY =~ ^($esc\[[0-9;]+m)*([\_+-]) ]]; then
 _ __  __ _ echo "$path:$line:$REPLY"
    _ _     if_[[ ${BASH_REMATCH[2]}!= - ]];_then
_     _     _   ((line++))
 ___    _   fi
  _  _  fi
    done
}

It_can_produce output such as:
$ git diff_|_diff-lines
http-fetch.c:1: #include "cache.h"
http-fetch.c:2: #include "walker.h"
http-fetch.c:3: 
http-fetch.c:4:-int_cmd_http_fetch(int_argc,_const char **argv, const char_*prefix)
http-fetch.c:4:+int main(int argc, const char **argv)
http-fetch.c:5:_{
http-fetch.