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

Re: [PATCH 0/1] git-apply: Allow simultaneous --cached and --3way options

From
Bagas Sanjaya <bagasdotme@gmail.com>
Date
Apr 3, 2021, 05:24 UTC
Message-ID
<0803a702-ae9c-da9a-c168-d534fe2aab58@gmail.com>
In-Reply-To
<20210403013410.32064-1-jerry@skydio.com>
On 03/04/21 08.34, Jerry Zhang wrote:
Show 57 quoted lines
> I'm creating a script/tool that will be able to cherry-pick
> multiple commits from a single branch, rebase them onto a
> base commit, and push those references to a remote.
> 
> Ex. with a branch like "origin/master -> A -> B -> C"
> The tool will create "master -> A", "master -> B",
> "master -> C" and either make local branches or
> push them to a remote. This can be useful since code
> review tools like github use branches as the basis
> for pull requests.
> 
> A key feature here is that the above happens without
> any changes to the user's working directory or cache.
> This is important since those operations will add
> time and generate build churn. We use these steps
> for synthesizing a "cherry-pick" of B to master.
> 
> 1. cp .git/index index.temp
> 2. set GIT_INDEX_FILE=index.temp
> 3. git reset master -- . (git read-tree also works here, but is a bit slower)
> 4. git format-patch --full-index B~..B
> 5. git apply --cached B.patch
> 6. git write-tree
> 7. git commit-tree {output of 6} -p master -m "message"
> 8. either `git symbolic-ref` to make a branch or `git push` to remote
> 
> I'm looking to improve the git apply step in #5.
> Currently we can't use --cached in combination with
> --3way, which limits some of the usefulness of this method.
> There are many diffs that will block applying a patch
> that a 3 way merge can resolve without conflicts. Even
> in the case where there are real conflicts, performing
> a 3 way merge will allow us to show the user the lines
> where the conflict occurred.
> 
> With the above in mind, I've created a small patch that
> implements the behavior I'd like. Rather than disallow
> the cached and 3way flags to be combined, we allow them,
> but write any conflicts directly to the cached file. Since
> we're unable to modify the working directory, it seems
> reasonable in this case to not actually present the user
> with any options to resolve conflicts. Instead, a script
> or tool using this command can diff the temporary cache
> to get the source of the conflict.
> 
> Happy to address any feedback. After I address any major
> changes I will add new tests for this path.
> 
> All tests passed locally.
> 
> Jerry Zhang (1):
>    git-apply: Allow simultaneous --cached and --3way options
> 
>   Documentation/git-apply.txt |  4 +++-
>   apply.c                     | 13 +++++++------
>   2 files changed, 10 insertions(+), 7 deletions(-)
> 

I know this patch series only have one patch, so why add the cover letter (PATCH 0/1)? Customarily, single-patch series just begin with `[PATCH] some title`, then patch message, and actual diff; all without cover letter.

-- 
An old man doll... just what I always wanted! - Clara
Previous: Jerry ZhangNext: Bagas Sanjaya
Message 28 of 29 in “git-apply: Allow simultaneous --cached and --3way options”
  1. 0/1 git-apply: Allow simultaneous --cached and --3way optionsJerry Zhang, Apr 3, 2021
  2. 1/1 git-apply: Allow simultaneous --cached and --3way optionsJerry Zhang, Apr 3, 2021
  3. Elijah NewrenApr 3, 2021
  4. Junio C HamanoApr 3, 2021
  5. Junio C HamanoApr 4, 2021
  6. Jerry ZhangApr 5, 2021
  7. Junio C HamanoApr 5, 2021
  8. Jerry ZhangApr 5, 2021
  9. Junio C HamanoApr 6, 2021
  10. Jerry ZhangApr 5, 2021
  11. git-apply: Allow simultaneous --cached and --3way optionsJerry Zhang, Apr 5, 2021
  12. Junio C HamanoApr 5, 2021
  13. Jerry ZhangApr 6, 2021
  14. Junio C HamanoApr 6, 2021
  15. Jerry ZhangApr 6, 2021
  16. Jerry ZhangApr 7, 2021
  17. git-apply: allow simultaneous --cached and --3way optionsJerry Zhang, Apr 6, 2021
  18. git-apply: allow simultaneous --cached and --3way optionsJerry Zhang, Apr 7, 2021
  19. Junio C HamanoApr 7, 2021
  20. git-apply: allow simultaneous --cached and --3way optionsJerry Zhang, Apr 8, 2021
  21. Junio C HamanoApr 8, 2021
  22. Elijah NewrenApr 12, 2021
  23. Junio C HamanoApr 12, 2021
  24. Elijah NewrenApr 12, 2021
  25. Junio C HamanoApr 12, 2021
  26. Elijah NewrenApr 3, 2021
  27. Jerry ZhangApr 5, 2021
  28. Bagas SanjayaApr 3, 2021
  29. Bagas SanjayaApr 3, 2021

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.