From: David Kågedal <david@xxxxxxxxxxxxx> Don't look in the "conflicts" file for that, since it isn't updated. Also added a test that the check_conflicts() function works. Signed-off-by: David Kågedal <davidk@xxxxxxxxxxxxxx> Signed-off-by: Karl Hasselström <kha@xxxxxxxxxxx> --- stgit/commands/common.py | 8 +++----- stgit/git.py | 18 ++++++++---------- t/t1203-push-conflict.sh | 6 ++++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/stgit/commands/common.py b/stgit/commands/common.py index f3fa89d..ad94caf 100644 --- a/stgit/commands/common.py +++ b/stgit/commands/common.py @@ -119,7 +119,7 @@ def check_head_top_equal(): ' into StGIT, use the "assimilate" command') def check_conflicts(): - if os.path.exists(os.path.join(basedir.get(), 'conflicts')): + if git.get_conflicts(): raise CmdException, \ 'Unsolved conflicts. Please resolve them first or\n' \ ' revert the changes with "status --reset"' @@ -152,10 +152,8 @@ def resolved(filename, reset = None): def resolved_all(reset = None): conflicts = git.get_conflicts() - if conflicts: - for filename in conflicts: - resolved(filename, reset) - os.remove(os.path.join(basedir.get(), 'conflicts')) + for filename in conflicts: + resolved(filename, reset) def push_patches(patches, check_merged = False): """Push multiple patches onto the stack. This function is shared diff --git a/stgit/git.py b/stgit/git.py index b6b5c3d..a375f38 100644 --- a/stgit/git.py +++ b/stgit/git.py @@ -157,14 +157,14 @@ def get_commit(id_hash): def get_conflicts(): """Return the list of file conflicts """ - conflicts_file = os.path.join(basedir.get(), 'conflicts') - if os.path.isfile(conflicts_file): - f = file(conflicts_file) - names = [line.strip() for line in f.readlines()] - f.close() - return names - else: - return None + names = [] + for line in GRun('git-ls-files', '-z', '--unmerged' + ).raw_output().split('\0')[:-1]: + stat, path = line.split('\t', 1) + # Look for entries in stage 2 (could equally well use 3) + if stat.endswith(' 2'): + names.append(path) + return names def exclude_files(): files = [os.path.join(basedir.get(), 'info', 'exclude')] @@ -203,8 +203,6 @@ def tree_status(files = None, tree_id = 'HEAD', unknown = False, # conflicted files conflicts = get_conflicts() - if not conflicts: - conflicts = [] cache_files += [('C', filename) for filename in conflicts] # the rest diff --git a/t/t1203-push-conflict.sh b/t/t1203-push-conflict.sh index 57fb477..afa52b2 100755 --- a/t/t1203-push-conflict.sh +++ b/t/t1203-push-conflict.sh @@ -53,6 +53,12 @@ test_expect_success \ git diff --cached --stat | grep -q -e "^ test2 | *1 " ' +test_expect_failure \ + 'Check that pop will fail while there are unmerged conflicts' \ + ' + stg pop + ' + test_expect_success \ 'Resolve the conflict' \ ' - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html