diff options
author | Stefan Lay <stefan.lay@sap.com> | 2010-11-29 17:58:38 +0100 |
---|---|---|
committer | Stefan Lay <stefan.lay@sap.com> | 2010-11-29 17:58:38 +0100 |
commit | 9225b88ae6b22eb6164434f62c5226ada777d277 (patch) | |
tree | bbfb422b0219e85ac45b6bea4010fe302755c7f3 /org.eclipse.jgit | |
parent | 12b635043506211fe9c873f14fc8e03546d6081d (diff) | |
download | jgit-9225b88ae6b22eb6164434f62c5226ada777d277.tar.gz jgit-9225b88ae6b22eb6164434f62c5226ada777d277.zip |
Check assume unchanged flag in Add command
When the assume unchanged flag is set the Add command must not update
the index for this file if any changes are present in the working
directory.
Bug: 331351
Change-Id: I255870f689225a1d88971182e0eb377952641b42
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java index 7a01e74b06..12a5201f6e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java @@ -163,25 +163,31 @@ public class AddCommand extends GitCommand<DirCache> { // new DirCacheEntry per path. else if (!(path.equals(lastAddedFile))) { if (!(update && tw.getTree(0, DirCacheIterator.class) == null)) { + c = tw.getTree(0, DirCacheIterator.class); if (f != null) { // the file exists long sz = f.getEntryLength(); DirCacheEntry entry = new DirCacheEntry(path); - entry.setLength(sz); - entry.setLastModified(f.getEntryLastModified()); - entry.setFileMode(f.getEntryFileMode()); - - InputStream in = f.openEntryStream(); - try { - entry.setObjectId(inserter.insert( - Constants.OBJ_BLOB, sz, in)); - } finally { - in.close(); + if (c == null || c.getDirCacheEntry() == null + || !c.getDirCacheEntry().isAssumeValid()) { + entry.setLength(sz); + entry.setLastModified(f.getEntryLastModified()); + entry.setFileMode(f.getEntryFileMode()); + + InputStream in = f.openEntryStream(); + try { + entry.setObjectId(inserter.insert( + Constants.OBJ_BLOB, sz, in)); + } finally { + in.close(); + } + + builder.add(entry); + lastAddedFile = path; + } else { + builder.add(c.getDirCacheEntry()); } - builder.add(entry); - lastAddedFile = path; } else if (!update){ - c = tw.getTree(0, DirCacheIterator.class); builder.add(c.getDirCacheEntry()); } } |