Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331472 - type change and rename wrong patch order
Summary: type change and rename wrong patch order
Status: RESOLVED WONTFIX
Alias: None
Product: JGit
Classification: Technology
Component: JGit (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-30 15:30 EST by Shawn Pearce CLA
Modified: 2010-12-03 16:42 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.