Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331472

Summary: type change and rename wrong patch order
Product: [Technology] JGit Reporter: Shawn Pearce <sop>
Component: JGitAssignee: Project Inbox <jgit.core-inbox>
Status: RESOLVED WONTFIX QA Contact:
Severity: major    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Shawn Pearce CLA 2010-11-30 15:30:49 EST
C Git and JGit differ about how a patch should appear when renaming a file and also creating a symlink at the old name location.

  $ git diff -M HEAD^ HEAD
  diff --git a/a b/a
  deleted file mode 100644
  index ce01362..0000000
  --- a/a
  +++ /dev/null
  @@ -1 +0,0 @@
  -hello
  diff --git a/a b/a
  new file mode 120000
  index 0000000..63d8dbd
  --- /dev/null
  +++ b/a
  @@ -0,0 +1 @@
  +b
  \ No newline at end of file
  diff --git a/b b/b
  new file mode 100644
  index 0000000..ce01362
  --- /dev/null
  +++ b/b
  @@ -0,0 +1 @@
  +hello

JGit correctly identifies the rename, but fails because the rename occurs after the symlink creation.  The rename needs to come first to ensure the old name is available for the symlink to create under:

  $ ../jgit/jgit diff -M HEAD^ HEAD
  diff --git a/a b/a
  new file mode 120000
  index 0000000..63d8dbd
  --- /dev/null
  +++ b/a
  @@ -0,0 +1 @@
  +b
  \ No newline at end of file
  diff --git a/a b/b
  similarity index 100%
  rename from a
  rename to b
Comment 1 Shawn Pearce CLA 2010-12-03 16:42:49 EST
Spoke to Junio C Hamano about this, turns out the patch order is fine.  git apply applies patches relative to the old tree, so actual order between files within a patch is irrelevant.  This permits concatenating two patches together, because that's what Linus Torvalds wanted to be able to do.