Download raw body.
got: wrong order of arguments in error reported by 'got diff'
I've following setup: edge:~/work/got$ got br -l jk: d6267a62d388995cbc79bb58ce9db7946fda0554 limit: 874f083e3301c63c77340ef9263c77bcb60514e8 * main: 47b307cd821b00964d3c5aea35c86689df2fe26d origin/HEAD: refs/remotes/origin/main origin/main: 47b307cd821b00964d3c5aea35c86689df2fe26d When I try to issue 'got diff master limit' (notice, 'master' instead of 'main', it was a typo) I get following error: edge:~/work/got$ got diff master limit got: limit: No such file or directory I think it's misleading to parse arguments from the end for such usage, personally I'd prefer it to tell that 'master' not found, it could point me to real source of the problem. I understand that in such scenario got parses 'master' and 'limit' as paths, not as branches. I also considered changes in got_worktree_resolve_path(), in branch when we get realpath(3), but current code deliberately ignores ENOENT error from it, and I don't fully understand why. Proposed patch: diff /home/ec2-user/work/got commit - e02b422b6f7736de0e851b3f8fad812e77e9c6b4 path + /home/ec2-user/work/got blob - 2fe9e120a0bace5a7b80643b8da00a79f1462de8 file + got/got.c --- got/got.c +++ got/got.c @@ -3348,7 +3348,7 @@ get_worktree_paths_from_argv(struct got_pathlist_head static const struct got_error * get_worktree_paths_from_argv(struct got_pathlist_head *paths, int argc, - char *argv[], struct got_worktree *worktree) + char *argv[], struct got_worktree *worktree, int native_order) { const struct got_error *err = NULL; char *path; @@ -3366,8 +3366,11 @@ get_worktree_paths_from_argv(struct got_pathlist_head err = got_worktree_resolve_path(&path, worktree, argv[i]); if (err) break; - err = got_pathlist_insert(&new, paths, path, NULL); - if (err || new == NULL /* duplicate */) { + if (native_order) + err = got_pathlist_append(paths, path, NULL); + else + err = got_pathlist_insert(&new, paths, path, NULL); + if (err || (!native_order && new == NULL /* duplicate */)) { free(path); if (err) break; @@ -3492,7 +3495,7 @@ cmd_update(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -5082,7 +5085,7 @@ cmd_diff(int argc, char *argv[]) } error = get_worktree_paths_from_argv(&paths, argc, argv, - worktree); + worktree, 1); if (error) goto done; @@ -6130,7 +6133,7 @@ cmd_status(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -6825,7 +6828,7 @@ cmd_branch(int argc, char *argv[]) if (error) goto done; error = get_worktree_paths_from_argv(&paths, 0, NULL, - worktree); + worktree, 0); if (error) goto done; if (asprintf(&branch_refname, "refs/heads/%s", argv[0]) @@ -7625,7 +7628,7 @@ cmd_add(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -7791,7 +7794,7 @@ cmd_remove(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -8286,7 +8289,7 @@ cmd_revert(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -8629,7 +8632,7 @@ cmd_commit(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -12424,7 +12427,7 @@ cmd_stage(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -12551,7 +12554,7 @@ cmd_unstage(int argc, char *argv[]) if (error) goto done; - error = get_worktree_paths_from_argv(&paths, argc, argv, worktree); + error = get_worktree_paths_from_argv(&paths, argc, argv, worktree, 0); if (error) goto done; @@ -13068,7 +13071,7 @@ cmd_info(int argc, char *argv[]) if (argc >= 1) { error = get_worktree_paths_from_argv(&paths, argc, argv, - worktree); + worktree, 0); if (error) goto done; show_files = 1;
got: wrong order of arguments in error reported by 'got diff'