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

Re: Remove old forgotten command: whatchanged

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 8, 2013, 06:39 UTC
Message-ID
<7vpptobsa2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<5202C109.6040209@googlemail.com>
Stefan Beller <stefanbeller@googlemail.com> writes:
Show 6 quoted lines
> Well if we make sure the whatchanged command can easily be reproduced
> with the log command, we could add the missing parameters to it, hence
> no change for the user. (git whatchanged == git log --raw --no-merges or
> git log --wc [to be done yet]).
>
> So I did not mean to introduce a change for users!

I certainly did *not* read that from between the lines of what you wrote:

+ int cmd_whatchanged(int argc, const char **argv, const char *prefix)
+ {
+ 	return cmd_log(argc, argv, prefix)
+ }

In principle, I agree that it is a good idea to try to share enough code, while keeping the flexiblity and clarity of the code for maintainability.

In the extreme, you could rewrite these two functions like so:
	static int cmd_lw_helper(
		int argc, const char **argv,
        	const char *prefix,
                int whoami)	
        {
		struct rev_info rev;
		struct setup_revision_opt opt;
        
		init_grep_defaults();
                git_config(git_log_config, NULL);
                init_revisions(&rev, prefix);
		if (whoami == 'l') { /* log */
	                rev.always_show_header = always_show_header;
		} else { /* whatchanged */
	                rev.diff = diff;
	                rev.simplify_history = simplify_history;
		}
                memset(opt, 0, sizeof(opt));
                opt.def = "HEAD";
                opt.revarg_opt = REVARG_COMMITTISH;
                cmd_log_init(argc, argv, prefix, &rev, &opt);
		if (whoami == 'w') {
			if (!rev.diffopt.output_format)
				rev.diffopt.output_format = DIFF_FORMAT_RAW;
		}
                return cmd_log_walk(&rev);
	}
        int cmd_log(int argc, const char **argv, const char *prefix)
	{
        	return cmd_lw_helper(argc, argv, prefix, 'l');
	}
        int cmd_whatchanged(int argc, const char **argv, const char *prefix)
	{
        	return cmd_lw_helper(argc, argv, prefix, 'w');
	}

but at that point, the cost you have to pay when you need to update one of them but not the other becomes higher.

As whatchanged is kept primarily for people who learned Git by word of mouth reading the kernel mailing list and are used to that command. Its external interface and what it does is not likely to drastically change. On the other hand, "log" is a primary Porcelain and we would expect constant improvements.

Between the "share more code for reuse" and "keep the flexibility and clarity for maintainability", it is a subtle balancing act. Personally I think the current code strikes a good balance by not going to the extreme, given that "change one (i.e. log) but not the other" is a very likely pattern for the evolution of these two commands.

Previous: Stefan BellerNext: Ramkumar Ramachandra
Message 5 of 31 in “Remove old forgotten command: whatchanged”
  1. Ramkumar RamachandraAug 7, 2013
  2. Stefan BellerAug 7, 2013
  3. Junio C HamanoAug 7, 2013
  4. Stefan BellerAug 7, 2013
  5. Junio C HamanoAug 8, 2013
  6. Ramkumar RamachandraAug 8, 2013
  7. Matthieu MoyAug 8, 2013
  8. Ramkumar RamachandraAug 8, 2013
  9. Matthieu MoyAug 8, 2013
  10. Junio C HamanoAug 8, 2013
  11. whatchanged: document its historical natureJunio C Hamano, Aug 9, 2013
  12. John KeepingAug 9, 2013
  13. Junio C HamanoAug 9, 2013
  14. John KeepingAug 12, 2013
  15. Junio C HamanoAug 13, 2013
  16. Ramkumar RamachandraAug 10, 2013
  17. Damien RobertAug 8, 2013
  18. Ramkumar RamachandraAug 8, 2013
  19. Matthieu MoyAug 8, 2013
  20. John KeepingAug 8, 2013
  21. Junio C HamanoAug 8, 2013
  22. Matthieu MoyAug 9, 2013
  23. Junio C HamanoAug 9, 2013
  24. Matthieu MoyAug 13, 2013
  25. Junio C HamanoAug 13, 2013
  26. Junio C HamanoAug 8, 2013
  27. Damien RobertAug 9, 2013
  28. Junio C HamanoAug 9, 2013
  29. Kyle J. McKayAug 7, 2013
  30. John KeepingAug 7, 2013
  31. Kyle J. McKayAug 7, 2013

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.