Skip to contentSkip to conversation

Finding leaf nodes.

DISCUSSION Jason Pyeron 2 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

I am trying to find all the unmerged commits [5].

I can find, as a human, all the commits by git log --oneline --graph --all [1] but I am looking for a scripted way.

But git show-branch -a --independent misses some [2]

find .git/refs/ -type f -exec cat '{}' ';' | sort -u; finds too much [3].

The closest I get is with refs=git show-ref -s; git log --format=%H $refs --not $(echo "$refs" | sed 's/$/^/') but it too [4] gives me extra, but I am really not sure why.

* | a54a4fb 
* | a0d2e63 
* | dd4400d 
| | *   68ea2c8
| | |\
| |/ /
|/| |
| | * c74d3c5 ??? Why is this the only extra commit listed ???
| |/
|/|
* | 9c87570 
* | 717e33d 
* | 159799f 

What should I do to automate this?

1:
0748f668b7fe0cba7a0edf1684ae84ddf87104ee
13916782bebe690149bfd1c3fb31d6d08942585b
383f3ae77393c2e303b3c32ef7dee122f0b623be
473093c214ba578cd7aecb6e2e5caaad70d173e4
4d0579c438e9d750f158124284bd740a5a0e0e26
68ea2c83978a7c023d76ebe438dd7d98fb1fd074
6900b076d790593a909bc84a1d062217e4a32941
9802bc44da0a35e4c7a917cd23468c387897cccd
982243cfde0dc6dfb1733d8e95748b7e687f57b8
c197b7f71cd6d601b99adbe0a5cf5bf6bc749b6e
c4bc3c4eb0015c73b50ea280a4a380e3cffc5160
c5234422373d0425fa9cd610cb0848b7c33fe436
d6af1c103b0cdeb7e7d45ffce2a838fa7a287aea
eb50b82c6f3f55b66693482a913a5c1cfc19a03d
f9c41c1a17df4358558a23a7c45bc2c60bf97e27
Fb962761aa2ce6fbf77e4769c9e418bbe6f9f47f

2:
4d0579c438e9d750f158124284bd740a5a0e0e26
68ea2c83978a7c023d76ebe438dd7d98fb1fd074
982243cfde0dc6dfb1733d8e95748b7e687f57b8
C4bc3c4eb0015c73b50ea280a4a380e3cffc5160

3:
00ea00e8e6a23a4243316f860aa07ed59203ab97
144eb9f673f14010c600766762b99cba1a64cc6e
2250af4ad29b92b07365320c5ccb7a22c17f588e
26bdfdfe71f7ceb4e0954bc5ab6c198481a280ae
283be0f77477fcd8c8bc878c602538f8a3451403
2f47330df8fb0357ef4e4d605d5c402150892a18
3ec60ab0dbdc63760429187605ede4549d7b2bad
43813b0fc44f7c41d2cdd4573145dbeb1aae1aee
4d5b52d440d3a64953a6d7ef3cbb81c8d289e392
556a5c2d759b51080e3bfe07a89b67e927749328
6fe0b6db2718625e5eeb3cbadeb58aa858ab4f1b
717e33d67ad3297a15cb432d3f70f7c12d353fa3
7587a45658aa689cc774d7253007be3feb2eec23
ad9b5fa90c8f52b3ca31dd433c2c4b408e5f2a8f
b3d7623b74dd75cc4f965d6b37dc461d2786f912
c19fc45c87de85122952d63d28a0c7d3a18b79d5
e8529e95d89d3f519a31ef7de5bd7f0d0d318e8c
f2e86371e7fe3391023adccd61856d088db773dd
fceca0050ceee8c4996a5740f7122e96c4948dd8

4:
c74d3c5cda60d8be7f38f1ec89c554a1346d57f8

5: My remotes:
https://github.com/CipherShed/CipherShed.git
https://github.com/pdinc-oss/CipherShed.git
https://github.com/discnl/CipherShed.git
https://github.com/eaglgenes101/CipherShed.git
https://github.com/erkinalp/CipherShed.git
https://github.com/GigabyteProductions/CipherShed.git
https://github.com/jeffallen/CipherShed.git
https://github.com/kaydiechii/CipherShed.git
https://github.com/srguglielmo/CipherShed.git

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- -

- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -

- -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.

#1 lore raw

Jason Pyeron venit, vidit, dixit 12.04.2015 06:04:

Quoted 1 line

I am trying to find all the unmerged commits [5].

"Unmerged" to which branch?

It's not clear to me which commits you are looking for. By "leaf node" I would describe a commit without child commits. "unmerged" can only be understood relative to a specific branch.

Maybe you are looking for commits from remote refs which are not on any local branch?

Quoted 3 lines

I can find, as a human, all the commits by git log --oneline --graph --all [1] but I am looking for a scripted way.

But git show-branch -a --independent misses some [2]

This finds refs which are not "contained in" (can be reached from) any of the other refs. If a remote ref is contained in another remore ref it is not listed.

Quoted 1 line

find .git/refs/ -type f -exec cat '{}' ';' | sort -u; finds too much [3].

This finds all refs.

Quoted 1 line

The closest I get is with refs=git show-ref -s; git log --format=%H $refs --not $(echo "$refs" | sed 's/$/^/') but it too [4] gives me extra, but I am really not sure why.

This finds all commits which are on some ref (branch/tag/..), excluding those which are next to the tip or higher up from those refs.

Quoted 9 lines
* | a54a4fb 
* | a0d2e63 
* | dd4400d 
| | *   68ea2c8
| | |\
| |/ /
|/| |
| | * c74d3c5 ??? Why is this the only extra commit listed ???

Because it is not "next to the tip", more specifically: not a first parent (foo^) of a referenced commit, and neither a predecessor of one.

Quoted 9 lines
| |/
|/|
* | 9c87570 
* | 717e33d 
* | 159799f 

What should I do to automate this?

Please try and restate what you mean by "unmerged commits". Maybe remote commits not on any local branch, or remote commits not on master?

Quoted 71 lines

1:
0748f668b7fe0cba7a0edf1684ae84ddf87104ee
13916782bebe690149bfd1c3fb31d6d08942585b
383f3ae77393c2e303b3c32ef7dee122f0b623be
473093c214ba578cd7aecb6e2e5caaad70d173e4
4d0579c438e9d750f158124284bd740a5a0e0e26
68ea2c83978a7c023d76ebe438dd7d98fb1fd074
6900b076d790593a909bc84a1d062217e4a32941
9802bc44da0a35e4c7a917cd23468c387897cccd
982243cfde0dc6dfb1733d8e95748b7e687f57b8
c197b7f71cd6d601b99adbe0a5cf5bf6bc749b6e
c4bc3c4eb0015c73b50ea280a4a380e3cffc5160
c5234422373d0425fa9cd610cb0848b7c33fe436
d6af1c103b0cdeb7e7d45ffce2a838fa7a287aea
eb50b82c6f3f55b66693482a913a5c1cfc19a03d
f9c41c1a17df4358558a23a7c45bc2c60bf97e27
Fb962761aa2ce6fbf77e4769c9e418bbe6f9f47f

2:
4d0579c438e9d750f158124284bd740a5a0e0e26
68ea2c83978a7c023d76ebe438dd7d98fb1fd074
982243cfde0dc6dfb1733d8e95748b7e687f57b8
C4bc3c4eb0015c73b50ea280a4a380e3cffc5160

3:
00ea00e8e6a23a4243316f860aa07ed59203ab97
144eb9f673f14010c600766762b99cba1a64cc6e
2250af4ad29b92b07365320c5ccb7a22c17f588e
26bdfdfe71f7ceb4e0954bc5ab6c198481a280ae
283be0f77477fcd8c8bc878c602538f8a3451403
2f47330df8fb0357ef4e4d605d5c402150892a18
3ec60ab0dbdc63760429187605ede4549d7b2bad
43813b0fc44f7c41d2cdd4573145dbeb1aae1aee
4d5b52d440d3a64953a6d7ef3cbb81c8d289e392
556a5c2d759b51080e3bfe07a89b67e927749328
6fe0b6db2718625e5eeb3cbadeb58aa858ab4f1b
717e33d67ad3297a15cb432d3f70f7c12d353fa3
7587a45658aa689cc774d7253007be3feb2eec23
ad9b5fa90c8f52b3ca31dd433c2c4b408e5f2a8f
b3d7623b74dd75cc4f965d6b37dc461d2786f912
c19fc45c87de85122952d63d28a0c7d3a18b79d5
e8529e95d89d3f519a31ef7de5bd7f0d0d318e8c
f2e86371e7fe3391023adccd61856d088db773dd
fceca0050ceee8c4996a5740f7122e96c4948dd8

4:
c74d3c5cda60d8be7f38f1ec89c554a1346d57f8

5: My remotes:
https://github.com/CipherShed/CipherShed.git
https://github.com/pdinc-oss/CipherShed.git
https://github.com/discnl/CipherShed.git
https://github.com/eaglgenes101/CipherShed.git
https://github.com/erkinalp/CipherShed.git
https://github.com/GigabyteProductions/CipherShed.git
https://github.com/jeffallen/CipherShed.git
https://github.com/kaydiechii/CipherShed.git
https://github.com/srguglielmo/CipherShed.git

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

(quoted diff) +0 -6
-                                                               -
- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -
-                                                               -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

This message is copyright PD Inc, subject to license 20080407P00.

#2 lore raw
Quoted 8 lines

-----Original Message-----
From: Michael J Gruber
Sent: Monday, April 13, 2015 10:23

Jason Pyeron venit, vidit, dixit 12.04.2015 06:04:

Quoted 1 line

I am trying to find all the unmerged commits [5].

"Unmerged" to which branch?

All. I was atempting to describe a leaf node.

Quoted 4 lines

It's not clear to me which commits you are looking for. By "leaf node" I
would describe a commit without child commits. "unmerged" can only be

That is exactly what I meant.

Quoted 5 lines

understood relative to a specific branch.

Maybe you are looking for commits from remote refs which are not on any
local branch?

Anywhere, that I know about. If the commit does not have a child, then that commit needs to be in the list, I do not care about the branches.

Quoted 10 lines
Quoted 2 lines

I can find, as a human, all the commits by git log

--oneline --graph --all [1] but I am looking for a scripted way.

Quoted 2 lines

But git show-branch -a --independent misses some [2]

This finds refs which are not "contained in" (can be reached from) any of the other refs. If a remote ref is contained in another remore ref it
is not listed.

Your description is logical, but how can a commit be included in "another remote ref"?

Quoted 5 lines
Quoted 2 lines

find .git/refs/ -type f -exec cat '{}' ';' | sort -u; finds

too much [3].

This finds all refs.

I know, the issue is I do not know how to filter it.

Quoted 19 lines
Quoted 2 lines

The closest I get is with refs=git show-ref -s; git log

--format=%H $refs --not $(echo "$refs" | sed 's/$/^/') but it too [4] gives me extra, but I am really not sure why.

This finds all commits which are on some ref (branch/tag/..), excluding
those which are next to the tip or higher up from those refs.

Quoted 9 lines
* | a54a4fb 
* | a0d2e63 
* | dd4400d 
| | *   68ea2c8
| | |\
| |/ /
|/| |
| | * c74d3c5 ??? Why is this the only extra commit listed ???
Quoted 3 lines

Because it is not "next to the tip", more specifically: not a first parent (foo^) of a referenced commit, and neither a predecessor of one.

I need to think on what you just said for this one.

Quoted 8 lines
Quoted 8 lines
| |/
|/|
* | 9c87570 
* | 717e33d 
* | 159799f 
Quoted 6 lines
Quoted 2 lines

What should I do to automate this?

Please try and restate what you mean by "unmerged commits". Maybe remote
commits not on any local branch, or remote commits not on master?

Regardless of branch references, I need to list all commits which do not have any child commits.

Quoted 4 lines
Quoted 4 lines

1:

See: yellow lines at http://client.pdinc.us/git-leaf-nodes-334e98c075877ce78b1ef959cb1155f7.html

Quoted 31 lines
Quoted 31 lines

2:
4d0579c438e9d750f158124284bd740a5a0e0e26
68ea2c83978a7c023d76ebe438dd7d98fb1fd074
982243cfde0dc6dfb1733d8e95748b7e687f57b8
C4bc3c4eb0015c73b50ea280a4a380e3cffc5160

3:
00ea00e8e6a23a4243316f860aa07ed59203ab97
144eb9f673f14010c600766762b99cba1a64cc6e
2250af4ad29b92b07365320c5ccb7a22c17f588e
26bdfdfe71f7ceb4e0954bc5ab6c198481a280ae
283be0f77477fcd8c8bc878c602538f8a3451403
2f47330df8fb0357ef4e4d605d5c402150892a18
3ec60ab0dbdc63760429187605ede4549d7b2bad
43813b0fc44f7c41d2cdd4573145dbeb1aae1aee
4d5b52d440d3a64953a6d7ef3cbb81c8d289e392
556a5c2d759b51080e3bfe07a89b67e927749328
6fe0b6db2718625e5eeb3cbadeb58aa858ab4f1b
717e33d67ad3297a15cb432d3f70f7c12d353fa3
7587a45658aa689cc774d7253007be3feb2eec23
ad9b5fa90c8f52b3ca31dd433c2c4b408e5f2a8f
b3d7623b74dd75cc4f965d6b37dc461d2786f912
c19fc45c87de85122952d63d28a0c7d3a18b79d5
e8529e95d89d3f519a31ef7de5bd7f0d0d318e8c
f2e86371e7fe3391023adccd61856d088db773dd
fceca0050ceee8c4996a5740f7122e96c4948dd8

4:
c74d3c5cda60d8be7f38f1ec89c554a1346d57f8

Quoted 10 lines
Quoted 10 lines

5: My remotes:
https://github.com/CipherShed/CipherShed.git
https://github.com/pdinc-oss/CipherShed.git
https://github.com/discnl/CipherShed.git
https://github.com/eaglgenes101/CipherShed.git
https://github.com/erkinalp/CipherShed.git
https://github.com/GigabyteProductions/CipherShed.git
https://github.com/jeffallen/CipherShed.git
https://github.com/kaydiechii/CipherShed.git
https://github.com/srguglielmo/CipherShed.git

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- -

- Jason Pyeron                      PD Inc. http://www.pdinc.us -
- Principal Consultant              10 West 24th Street #100    -
- +1 (443) 269-1555 x333            Baltimore, Maryland 21218   -

- -
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
This message is copyright PD Inc, subject to license 20080407P00.