git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (resend)] Pass -C1 to git-apply in StGIT's apply_diff() and apply_patch().

From
TBTomash Brechko <tomash.brechko@gmail.com>
Date
Apr 9, 2007, 11:24 UTC
Message-ID
<20070409112422.GE11593@moonlight.home>

Running git-apply without -C is too restrictive: when the patch has some fuzz (it could have been applied upstream with the fuzz, or different local branches have slightly different context), StGIT would start manual merge because of the conflict in the context. Passing -C1 makes git-apply behave close to default mode of diff/patch: 'diff' generates 3 lines of context, and 'patch' allows 2 line mismatch, i.e. it requires the match of at least one context line.

Fix in apply_diff() relaxes the restriction in 'push --merged' and 'rebase --merged' for detection of upstream merges, fix in apply_patch() does relaxation 'import', 'fold' and 'sync' commands.

This patch is a quick hack, better solution would be to have a control
over the value to -C option, or to have the option similar to
git-cvsexportcommit -p (pedantic mode).
---
 stgit/git.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/stgit/git.py b/stgit/git.py
index f6d6b43..bbb41fe 100644
--- a/stgit/git.py
+++ b/stgit/git.py
@@ -660,7 +660,7 @@ def apply_diff(rev1, rev2, check_index = True, files = None):
     diff_str = diff(files, rev1, rev2)
     if diff_str:
         try:
-            _input_str('git-apply %s' % index_opt, diff_str)
+            _input_str('git-apply -C1 %s' % index_opt, diff_str)
         except GitException:
             return False
 
@@ -930,7 +930,7 @@ def apply_patch(filename = None, diff = None, base = None,
         refresh_index()
 
     try:
-        _input_str('git-apply --index', diff)
+        _input_str('git-apply -C1 --index', diff)
     except GitException:
         if base:
             switch(orig_head)
-- 
1.5.1.82.g46af1-dirty
Next: Catalin Marinas
Message 1 of 6 in “Pass -C1 to git-apply in StGIT's apply_diff() and apply_patch().”
  1. Pass -C1 to git-apply in StGIT's apply_diff() and apply_patch().Tomash Brechko, Apr 9, 2007
  2. Catalin MarinasApr 10, 2007
  3. Tomash BrechkoApr 10, 2007
  4. Tomash BrechkoApr 10, 2007
  5. Catalin MarinasApr 10, 2007
  6. Tomash BrechkoApr 11, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.