{"thread":{"id":"35921","subject":"feature-request: git notes copy --to <ref>","startedAt":"2014-02-20T21:03:34Z","lastAt":"2014-03-17T10:11:44Z","messageCount":2,"participants":["Uwe Kleine-König"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"235111","messageId":"20140220210334.GM6988@pengutronix.de","threadId":"35921","inReplyTo":null,"subject":"feature-request: git notes copy --to <ref>","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2014-02-20T21:03:34Z","receivedAt":"2014-02-20T21:03:34Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello,\n\nI'm playing around with git-notes and want to share some of my notes\nwith my co-workers. We have a central repository for our various topic\nbranches and want to track upstream inclusion in git-notes. So we have\nto share our notes branch somehow.\n\nThe workflow I think makes sense here is (untested):\n\n\t### hack hack, add notes bla blub\n\t### -> nice topic branch with some notes\n\n\tgit fetch serverrepo refs/notes/commits:refs/notes/servercommits\n\tgit notes merge refs/notes/servercommits\n\tgit rev-list origin/master.. | awk '{print $1 \" \" $1}' | git notes copy --to refs/notes/servercommits --stdin\n\tgit push serverrepo refs/notes/servercommits:refs/notes/commits\n\nThen maybe:\n\n\tgit notes merge refs/notes/servercommits\n\nagain.\n\nThe idea here is to only include notes in refs/notes/servercommits that\nare relevant for my coworkers and not all intermediate notes that were\ncreated during development or while working on other branches.\n\nDoes this make sense? Do you have better ideas or suggestions how to\nimprove the workflow?\n\nThe only problem now is that git notes copy doesn't take a --to\nparameter. Maybe there is a volunteer to implement it? Then I'd\nvolunteer to test it :-)\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"},{"id":"236870","messageId":"20140317101144.GO15674@pengutronix.de","threadId":"35921","inReplyTo":"20140220210334.GM6988@pengutronix.de","subject":"Re: feature-request: git notes copy --to <ref>","fromName":"Uwe Kleine-König","fromEmail":"u.kleine-koenig@pengutronix.de","sentAt":"2014-03-17T10:11:44Z","receivedAt":"2014-03-17T10:11:44Z","isPatch":false,"sender":{"key":"u.kleine-koenig@pengutronix.de","avatar":"https://gravatar.com/avatar/354b5e3ceb2806a2f1e1e382ac29ddbdad18288654da62b61eb13583a857eee7?d=mp&s=160"},"body":"Hello again,\n\nOn Thu, Feb 20, 2014 at 10:03:34PM +0100, Uwe Kleine-König wrote:\n> I'm playing around with git-notes and want to share some of my notes\n> with my co-workers. We have a central repository for our various topic\n> branches and want to track upstream inclusion in git-notes. So we have\n> to share our notes branch somehow.\n> \n> The workflow I think makes sense here is (untested):\n> \n> \t### hack hack, add notes bla blub\n> \t### -> nice topic branch with some notes\n> \n> \tgit fetch serverrepo refs/notes/commits:refs/notes/servercommits\n> \tgit notes merge refs/notes/servercommits\n> \tgit rev-list origin/master.. | awk '{print $1 \" \" $1}' | git notes copy --to refs/notes/servercommits --stdin\n> \tgit push serverrepo refs/notes/servercommits:refs/notes/commits\n> \n> Then maybe:\n> \n> \tgit notes merge refs/notes/servercommits\n> \n> again.\n> \n> The idea here is to only include notes in refs/notes/servercommits that\n> are relevant for my coworkers and not all intermediate notes that were\n> created during development or while working on other branches.\n> \n> Does this make sense? Do you have better ideas or suggestions how to\n> improve the workflow?\n> \n> The only problem now is that git notes copy doesn't take a --to\n> parameter. Maybe there is a volunteer to implement it? Then I'd\n> volunteer to test it :-)\nI have implemented something now to copy notes to another branch. Here\nis it for reference:\n\n--->8---\n#! /bin/sh\n\nset -e\n\n. git-sh-setup\n\n# for now the remote notes rev must be a ref below refs/notes\n# see id:20140220153045.GI6988@pengutronix.de for the respective plea.\nremote_notes=\"refs/notes/servercommits\"\nlocal_notes=\"$(git notes get-ref)\"\n\nremote_notes_ref=$(git rev-parse --verify \"$remote_notes^{commit}\")\n\ntmpfile=$(mktemp)\ntrap \"rm \\\"$tmpfile\\\"\" EXIT\n\ngit rev-list \"$@\" | sed 's/^/100644 blob [0-9a-f]{40}\\t/' > $tmpfile\n\nGIT_DIR=$(git rev-parse --git-dir)\n\nGIT_INDEX_FILE=\"$GIT_DIR/index-rnotes\" git read-tree \"$remote_notes\"\ngit ls-tree \"$local_notes\" | grep -E -f \"$tmpfile\" | GIT_INDEX_FILE=\"$GIT_DIR/index-rnotes\" git update-index --index-info\n\ntree=$(GIT_INDEX_FILE=\"$GIT_DIR/index-rnotes\" git write-tree)\n\nif test \"x$tree\" = \"x$(git rev-parse \"$remote_notes_ref^{tree}\")\"; then\n\techo \"empty commit\"\n\texit 0\nfi\n\ncommit=$(git commit-tree \"$tree\" -p \"$remote_notes_ref\" << EOF\nNotes added by 'git notes-copy'\n\nsource notes: $(git rev-parse $local_notes)\nEOF\n)\n\ngit update-ref \"$remote_notes\" $commit $remote_notes_ref\n--->8---\n\nIt still has some edges, but I think it will do for me. Enhancements\nwelcome.\n\nBest regards\nUwe\n\n-- \nPengutronix e.K.                           | Uwe Kleine-König            |\nIndustrial Linux Solutions                 | http://www.pengutronix.de/  |\n"}]}