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

[SCRIPT/RFC 1/3] setup.sh

From
IDIgor Djordjevic <igor.d.djordjevic@gmail.com>
Date
Nov 26, 2017, 22:36 UTC
Message-ID
<397276a1-8f2b-117d-ce51-84ab832ce562@gmail.com>
In-Reply-To
<8998e832-f49f-4de4-eb8d-a7934fba97b5@gmail.com>
On 26/11/2017 23:35, Igor Djordjevic wrote:
Show 14 quoted lines
> 
> This is what we end up with once "master" and topic branches are 
> merged in merge commit M1 inside temporary "test" branch for further 
> integration testing:
> 
> (2)        o---o---A (topicA)
>           /         \
>          /           M1 (test, HEAD)
>         /           /||
>     ---o---o---M---/ || (master)
>         \   \       / |
>          \   o---B-/  | (topicB)
>           \           |
>            o---o---C--/ (topicC)

To begin with, you can use provided "setup.sh"[*1*] script, putting you straight into position shown on graph (2) above, with addition of tag "A" and remote branch "origin/topicA" so you could try using these as "--onto-parent" values, too.

As seen in there, change "X" is already made and staged, so you can now just run something like:

	git-commit--onto-parent.sh --onto-parent topicA
... to see the logic in action.
 
Instead of "topicA", you may try providing tag "A", remote branch 
"origin/topicA" or even plain commit hash. It`s interesting to add 
"--amend" option into the mix, too, and see what happens. Also, you 
can try using "topicB" and see the commit fail (as it doesn`t merge 
cleanly).

All this while "test.txt" file doesn`t get modified on disk (nor would any other file) - being desired behaviour, as we didn`t actually change anything inside the working tree, but just amended history of how we got here, so recompilation isn`t needlessly triggered :)

p.s. Note these two lines near the end:
	sed -i '4iX1' test.txt  # works with simple patch apply
	sed -i '17iX2' test.txt # needs three-way file merge

You can play with it, commenting out one or the other and observing how it influences "git commit --onto-parent" in regards of the parent provided.

Regards, Buga
[*1*] "setup.sh", can clean previous setup run as well, but commented 
 out here for safety, not to unexpectedly delete something for unwary 
 user.
--- 8< ---
#!/bin/sh

#rm -rf ./.git #rm -f ./test.txt

git init

touch ./test.txt git add -- test.txt

for i in {1..10}
do
	echo $i >>test.txt	
	git commit -am "$i"
done

echo M >>test.txt git commit -am "M"

git checkout -b topicA HEAD~2
for i in 1 2
do
	sed -i "${i}iA${i}" test.txt
	git commit -am "A$i"
done
sed -i '3iA' test.txt
git commit -am "A"
git tag A

# simulate remote branch mkdir -p ./.git/refs/remotes/origin && echo $(git rev-parse HEAD^0) >$_/topicA

git checkout -b topicB master^

sed -i '4iB1' test.txt git commit -am "B1" sed -i '5iB' test.txt git commit -am "B"

git checkout -b topicC master~2
for i in 1 2
do
	j=`expr "$i" + 5`
	sed -i "${j}iC${i}" test.txt
	git commit -am "C$i"
done
sed -i "8iC" test.txt
git commit -am "C"

git checkout -b test master git merge --no-edit topicA topicB topicC

sed -i '4iX1' test.txt # works with simple patch apply sed -i '17iX2' test.txt # needs three-way file merge git add -- test.txt

echo git log --all --decorate --oneline --graph echo git diff --cached

Previous: Igor DjordjevicNext: Igor Djordjevic
Message 2 of 26 in “[SCRIPT/RFC 0/3] git-commit --onto-parent (three-way merge, no working tree file changes)”
  1. Igor DjordjevicNov 26, 2017
  2. 1/3 setup.shIgor Djordjevic, Nov 26, 2017
  3. 3/3 git-commit--onto-parent.shIgor Djordjevic, Nov 26, 2017
  4. 2/3 git-merge-one-file--cachedIgor Djordjevic, Nov 26, 2017
  5. Johannes SixtNov 27, 2017
  6. Igor DjordjevicNov 28, 2017
  7. Johannes SixtNov 29, 2017
  8. Igor DjordjevicNov 29, 2017
  9. Johannes SixtDec 1, 2017
  10. Igor DjordjevicDec 4, 2017
  11. Johannes SixtDec 6, 2017
  12. Junio C HamanoDec 6, 2017
  13. Igor DjordjevicDec 8, 2017
  14. Junio C HamanoDec 8, 2017
  15. Igor DjordjevicDec 8, 2017
  16. Alexei LozovskyDec 9, 2017
  17. Igor DjordjevicDec 9, 2017
  18. Phillip WoodDec 9, 2017
  19. Igor DjordjevicDec 10, 2017
  20. Phillip WoodDec 10, 2017
  21. Igor DjordjevicDec 10, 2017
  22. Alexei LozovskyDec 11, 2017
  23. Alexei LozovskyDec 11, 2017
  24. Phillip WoodDec 9, 2017
  25. Chris NerwertNov 30, 2017
  26. Igor DjordjevicDec 3, 2017

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.