Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
COMP90048 Declarative Programming
This assignment aims to give you
Note: the material in the lecture notes will not be sufficient by itself to allow you to complete this assignment. You may need to search on-line documentation for Shell, git, Perl etc. Being able to search documentation efficiently for the information you need is a very useful skill for any kind of computing work.
Your task in this assignment is to write Shell & Perl programs which implement a subset of the version control system Git.
Git is a very complex program which has many individual commands. You will implement only a few of the most important commands.
You will be given a number of simplifying assumptions which make your task easier.
Many aspects of this assignment are not fully specified in this document.
Instead you must match the behaviour of reference implementations.
For example your script legit-add should match the behaviour of 2041 legit-add exactly, including producing the same error messages.
Provision of a reference implementation is a common method to provide an operational specification, and it’s something you will likely need to do after you leave UNSW.
Discovering & matching the reference implementation’s behaviour is deliberately part of the assignment.
While the code in the reference implementation is fairly straight forward, reverse-engineering its behaviour is obviously not so simple and it’s a nice example of how coming to grips with the precise semantics of an apparently obvious task can still be challenging.
If you discover what you believe to be a bug in the reference implementation, report it in the class forum. Andrew may fix the bug or indicate that you do not need to match the reference implementation’s behaviour in this case.
Subset 0 commands must be implemented in POSIX-compatible Shell. See the Permitted Languages section for more information.
The legit-init command creates an empty Legit repository.
legit-init should create a directory named .legit which it will use to store the repository.
It should produce an error message if this directory already exists. You should match this and other error messages exactly. For example:
ls -d .legitls: cannot access '.legit': No such file or directorylegit-initInitialized empty legit repository in .legitls -d .legit.legitlegit-initlegit-init: error: .legit already existslegit-init may create initial files or directories inside .legit.
You do not have to use a particular representation to store the repository.
You do not have to create the same files or directory inside legit-init as the reference implementation.
The legit-add command adds the contents of one or more files to the “index“.
Files are added to the repository in a two step process. The first step is adding them to the index.
You will need to store files in the index somehow in the .legit sub-directory. For example you might choose store them in a sub-directory of .legit.
Only ordinary files in the current directory can be added, and their names will always start with an alphanumeric character ([a-zA-Z0-9]) and will only contain alpha-numeric characters plus ‘.’, ‘-‘ and ‘_’ characters.
The legit-add command, and other legit commands, will not be given pathnames with slashes.
The legit-commit command saves a copy of all files in the index to the repository.
A message describing the commit must be included as part of the commit command.
legit commits are numbered (not hashes like git). You must match the numbering scheme.
You can assume the commit message is ASCII, does not contain new-line characters and does not start with a ‘-‘ character.
The legit-log command prints one line for every commit that has been made to the repository.
Each line should contain the commit number and the commit message.
The legit-show should print the contents of the specified file as of the specified commit.
If the commit is omitted the contents of the file in the index should be printed.