From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 06A461F5AE for ; Fri, 23 Apr 2021 22:43:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231881AbhDWWoV (ORCPT ); Fri, 23 Apr 2021 18:44:21 -0400 Received: from mav.lukeshu.com ([104.207.138.63]:35832 "EHLO mav.lukeshu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232500AbhDWWoU (ORCPT ); Fri, 23 Apr 2021 18:44:20 -0400 Received: from lukeshu-dw-thinkpad (unknown [IPv6:2601:281:8200:26:4e34:88ff:fe48:5521]) by mav.lukeshu.com (Postfix) with ESMTPSA id 3027D80590; Fri, 23 Apr 2021 18:43:35 -0400 (EDT) Date: Fri, 23 Apr 2021 16:43:34 -0600 Message-ID: <87tunw1v1l.wl-lukeshu@lukeshu.com> From: Luke Shumaker To: Eric Sunshine Cc: Luke Shumaker , Git List , Avery Pennarun , Charles Bailey , Danny Lin , "David A . Greene" , David Aguilar , Jakub Suder , James Denholm , Jeff King , Jonathan Nieder , Junio C Hamano , =?UTF-8?B?Tmd1?= =?UTF-8?B?eeG7hW4g?= =?ISO-8859-1?Q?Th=E1i_?= =?UTF-8?B?Tmfhu41j?= Duy , Roger L Strain , Techlive Zheng , Luke Shumaker Subject: Re: [PATCH 12/30] subtree: don't have loose code outside of a function In-Reply-To: References: <20210423194230.1388945-1-lukeshu@lukeshu.com> <20210423194230.1388945-13-lukeshu@lukeshu.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.2 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Fri, 23 Apr 2021 14:23:18 -0600, Eric Sunshine wrote: > > On Fri, Apr 23, 2021 at 3:43 PM Luke Shumaker wrote: > > Shove all of the loose code inside of a main() function. > > > > "Ignore space change" is probably helpful when viewing this diff. > > > > Signed-off-by: Luke Shumaker > > What is the purpose of this change? Does some subsequent commit depend > upon this or is it just a personal preference? The commit message > explains the "what" of the change but not the "why". Dropping the commit would surely cause me much trouble with rebasing both the subsequent commits in this patchset and the commits I haven't yet submitted. But I don't think they "depend" on it. I guess it is personal preference... one that I've developed from years of maintaining Bash scripts. It's in a nearby part of my brain to "avoid global variables". It's related to my notion that the reason most people think shell scripts are so terrible is that most people don't treat it like a real programming language and don't apply normal programming best practices; that not littering code around outside of a function is part of treating it like a real language (at least once the program grows beyond a certain size, which git-subtree surely has). It's probably related to the Python idiom if __name__ == "__main__": main() that is often seen at the bottom of Python scripts. In this specific case, it's also moving the `set -- -h`, the `git rev-parse --parseopt`, and the `. git-sh-setup` to be closer to all the rest of the argument parsing, which is a readability win on its own, IMO. -- Happy hacking, ~ Luke Shumaker