Fix import to work properly in subdirectories
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 9 Sep 2008 22:11:16 +0000 (23:11 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 9 Sep 2008 22:11:16 +0000 (23:11 +0100)
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/imprt.py
t/t1800-import.sh

index 1c21a74..cd44d3f 100644 (file)
@@ -279,6 +279,10 @@ def func(parser, options, args):
     else:
         filename = None
 
+    if filename:
+        filename = os.path.abspath(filename)
+    directory.cd_to_topdir()
+
     if options.series:
         __import_series(filename, options)
     elif options.mbox:
index 8c8c9a0..624e51c 100755 (executable)
@@ -22,6 +22,17 @@ test_expect_success \
     '
 
 test_expect_success \
+    'Apply a patch created with "git diff" from a subdirectory' \
+    '
+    mkdir subdir && cd subdir &&
+    stg import ../../t1800-import/git-diff &&
+    [ $(git cat-file -p $(stg id) \
+        | grep -c "tree e96b1fba2160890ff600b675d7140d46b022b155") = 1 ] &&
+    stg delete .. &&
+    cd ..
+    '
+
+test_expect_success \
     'Apply a patch created with GNU diff' \
     '
     stg import ../t1800-import/gnu-diff &&