Using the JGIT, how can I retrieve the line numbers of added/deleted lines

前端 未结 3 1212
梦谈多话
梦谈多话 2021-02-20 16:56

Assuming the following piece of code is committed to a Git repository:

int test(){
   int a = 3;
   int b = 4;
   int c = a + b;
   return c;
}

3条回答
  •  爱一瞬间的悲伤
    2021-02-20 17:55

    Just a tip for anyone who might have this problem. I did not manage to get the line numbers of the added and deleted lines but I did manage to get a string which contains only the added and deleted lines without the other lines which were not changed.

    This was simply done by adding the line:

       df.setContext(0);
    

    in the snippet I provided above right before the line

       df.format(diff);
    

提交回复
热议问题