Add '--' to git-diff-index calls
authorCatalin Marinas <catalin.marinas@gmail.com>
Wed, 5 Jul 2006 18:27:02 +0000 (19:27 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Wed, 5 Jul 2006 18:27:02 +0000 (19:27 +0100)
Without this, git-diff-index was confused about the command line arguments
and commands like 'push --undo' and 'status --reset' failed to work
properly.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/git.py
t/t1202-push-undo.sh [new file with mode: 0755]

index b7f3269..c8b7b8f 100644 (file)
@@ -210,7 +210,7 @@ def __tree_status(files = None, tree_id = 'HEAD', unknown = False,
     cache_files += [('C', filename) for filename in conflicts]
 
     # the rest
-    for line in _output_lines(['git-diff-index', tree_id] + files):
+    for line in _output_lines(['git-diff-index', tree_id, '--'] + files):
         fs = tuple(line.rstrip().split(' ',4)[-1].split('\t',1))
         if fs[1] not in conflicts:
             cache_files.append(fs)
@@ -571,13 +571,13 @@ def diff(files = None, rev1 = 'HEAD', rev2 = None, out_fd = None):
         files = []
 
     if rev1 and rev2:
-        diff_str = _output(['git-diff-tree', '-p', rev1, rev2] + files)
+        diff_str = _output(['git-diff-tree', '-p', rev1, rev2, '--'] + files)
     elif rev1 or rev2:
         refresh_index()
         if rev2:
-            diff_str = _output(['git-diff-index', '-p', '-R', rev2] + files)
+            diff_str = _output(['git-diff-index', '-p', '-R', rev2, '--'] + files)
         else:
-            diff_str = _output(['git-diff-index', '-p', rev1] + files)
+            diff_str = _output(['git-diff-index', '-p', rev1, '--'] + files)
     else:
         diff_str = ''
 
diff --git a/t/t1202-push-undo.sh b/t/t1202-push-undo.sh
new file mode 100755 (executable)
index 0000000..335b554
--- /dev/null
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Catalin Marinas
+#
+
+test_description='Exercise push --undo with missing files.
+
+Test the case where a patch fails to be pushed because it modifies a
+missing file. The "push --undo" command has to be able to revert it.
+'
+
+. ./test-lib.sh
+
+test_expect_success \
+       'Initialize the StGIT repository' \
+       'stg init
+'
+
+test_expect_success \
+       'Create the first patch' \
+       '
+       stg new foo -m foo &&
+       echo foo > test &&
+       stg add test &&
+       stg refresh
+       '
+
+test_expect_success \
+       'Create the second patch' \
+       '
+       stg new bar -m bar &&
+       echo bar > test &&
+       stg add test &&
+       stg refresh
+       '
+
+test_expect_success \
+       'Pop all patches' \
+       '
+       stg pop --all
+       '
+
+test_expect_failure \
+       'Push the second patch with conflict' \
+       '
+       stg push bar
+       '
+
+test_expect_success \
+       'Undo the previous push' \
+       '
+       stg push --undo
+       '
+
+test_done