From: Klemens Nanni Subject: Re: got diff: add support for multiple path arguments To: gameoftrees@openbsd.org Date: Thu, 7 Oct 2021 20:59:31 +0000 On Thu, Oct 07, 2021 at 02:18:16PM +0200, Stefan Sperling wrote: > Make "got diff path1 path2 path3 ..." produce a diff of the > corresponding paths in a work tree. This is so much more useful, so no objection from but, but I'd like to see got's diff semantics become more similar to git's eventually, simply because they are so helpful. More on this inline. > This feature has been requested several times already. I gave it a try some time ago but failed implementing it another way... OK kn > fprintf(stderr, "usage: %s diff [-a] [-C number] [-r repository-path] " > - "[-s] [-w] [object1 object2 | path]\n", getprogname()); > + "[-s] [-w] [-P] [object1 object2 | path ...]\n", getprogname()); So either two objects or some number of paths, but even better would be got diff [-aswP] [-r repo] [object1 object2] [--] [path ...] Diff an arbitrary number of paths in the current worktree against HEAD or, iff two objects are given, between those two commits/branches/etc. I use this with git all the time as it is helpful to get an overview of what changed between say two versions, e.g. git diff 6.9 7.0 -- sys/net (More precisely, I use that with `git log -p' so I get to browse history for a specific time frame and for specific files only.) > + if (worktree != NULL && (ids[0] == NULL || ids[1] == NULL)) { > + error = get_worktree_paths_from_argv(&paths, > + argc, argv, worktree); > + if (error) > + goto done; > + } get_worktree_paths_from_argv() should probably ensure a unique list, i.e. neither `got diff -P a a' nor `got diff -P a ./a' should diff "a" twice. That's also how git behaves. Not that important and something for a another diff.